<a href="<?=htmlspecialchars(str_replace($this->pageVar, $this->page - 1, $this->pattern));?>" class="action_button small next" <?php echo ($this->page <= 1 ? 'style="visibility: hidden;"' : ''); ?>><span>&lt;</span></a>
<?php


if ($this->totalPages >= 2)
{
	$surr = 4;
	$start = max(2, $this->page - $surr);
	$end = min($this->totalPages - 1, $this->page + $surr);
	
	$sPages = array();
	if ($start <= $end) $sPages = range($start, $end);
	
	array_unshift($sPages, 1);
	array_push($sPages, $this->totalPages);
	
	for ($i = 0; $i < sizeof($sPages); $i ++)
	{
	    ?>
		<a href="<?=htmlspecialchars(str_replace($this->pageVar, $sPages[$i], $this->pattern));?>" class="<?=($sPages[$i] == $this->page ? 'action_button small active' : 'action_button small');?>"><span><?=$sPages[$i];?></span></a>
		<?
	    if (isset($sPages[$i + 1]) && (($sPages[$i] + 1) != $sPages[$i + 1]))
	    {
	    	?><span>&hellip;</span><?
	    }
	}

	?><a href="<?=htmlspecialchars(str_replace($this->pageVar, $this->page + 1, $this->pattern));?>" class="action_button small next" <?php echo ($this->totalPages <= $this->page ? 'style="visibility: hidden;"' : ''); ?>><span>&gt;</span></a><?php
}